<!DOCTYPE html>
<!--suppress ThymeleafVariablesResolveInspection-->
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="Responsive Admin Dashboard Template">
        <meta name="keywords" content="admin,dashboard">
        <meta name="author" content="skcats">
		<title></title>
		<link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
        <link th:href="@{/assets/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
        <link th:href="@{/assets/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
        <link th:href="@{/assets/css/custom.css}" rel="stylesheet">
	</head>
	<style>
    .layui-table-page {
        text-align: center;
    }

    .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
        background-color: #1E9FFF;
    }
    .layui-input-inline{margin-left: 50px;}
    .layui-form-item{margin-top: 20px;}
    .layui-form-label{width: 80px;}
    .layui-table-view thead th {
        text-align: center;
        font-weight: bold;
    }
    .layui-table-view tbody td {
        text-align: center;
    }
	</style>
<body>
<!--数据表格样式及附件-->
<script type="text/html" id="bar">
    {{#  if(d.status == 1){ }}
    <a id="ann" class="layui-btn layui-btn-warm layui-btn-xs" lay-event="no">
        <i class="layui-icon">&#xe642;</i>禁用
    </a>
    {{# }if(d.status == 2) { }}
    <a class="layui-btn layui-btn-xs" lay-event="yes">
        <i class="layui-icon">&#xe642;</i>启用
    </a>
    {{#  } }}
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">
        <i class="layui-icon">&#xe640;</i>丢弃
    </a>
</script>

<!--数据表格  数据表格使用的是方法渲染-->
<div class="utable">
<table class="layui-table"
       lay-data="{width:1150,height:650, url:'/wxgl/equiwxgldata', page:true, id:'tab'}"
       lay-filter="tab">
    <thead>
    <tr>
        <th lay-data="{type: 'checkbox', fixed: 'left'}"></th>
        <th lay-data="{field:'wxid', width:80, sort: true}">ID</th>
        <th lay-data="{field:'equipmenttype'}">维修设备名称</th>
        <th lay-data="{field:'usertype', templet: '#bmbj'}">部门/班级</th>
        <th lay-data="{field:'starttime'}">开始时间</th>
        <th lay-data="{field:'endtime'}" id="jssj">结束时间</th>
        <th lay-data="{field:'status', templet: '#zt'}">维修状态</th>
        <th lay-data="{fixed: 'right', title:'操作', toolbar: '#bar', width:252}"></th>
    </tr>
    </thead>
</table>
</div>
</body>
<script th:src="@{/js/register/jquery-3.1.0.min.js}"></script>
<script th:src="@{/layui/layui.js}"></script>
<!--<script type="text/html" id="bmbj">-->
    <!--{{#  if(d.usertype ==1 ){ }}-->
    <!--{{d.starttime}}-->
    <!--{{#  } else { }}-->
    <!--{{d.endtime}}-->
    <!--{{#  } }}-->


    <!--{{#  if(d.usertype ==1 ){ }}-->
    <!--<p>部门</p>-->
    <!--{{#  } else { }}-->
    <!--<p>班级</p>-->
    <!--{{#  } }}-->
<!--</script>-->
<script type="text/html" id="zt">
    {{#  if(d.status ==1 ){ }}
    <p>未修好</p>
    {{#  } else { }}
    <p>已修好</p>
    {{#  } }}
</script>
<script type="text/javascript" th:inline="none">

    layui.use('table', function () {
        var table = layui.table;

        //监听行工具事件
        table.on('tool(tab)', function (obj) {
            var data = obj.data;
            //console.log(obj)
            if (obj.event === 'de' +
                '' +
                '' +
                'l') {
                layer.confirm('真的删除么?', function (index) {
                    obj.del();
                    layer.close(index);
                    $.ajax({
                        url: '/wxgl/wxgldel',
                        type: 'post',
                        data: {
                            wxid:data.wxid
                        },
                        dataType: 'text'
                    })
                });
            }else if (obj.event == "yes") {//禁用
                $.ajax({
                    url: '/wxgl/set',
                    type: 'post',
                    data: {
                        wxid:data.wxid,
                        status:data.status,
                    },
                    dataType: 'json',
                    success : function(data) {
                        if (data){
                            //执行重载
                            $('.layui-laypage-btn').click();
                            //document.location.href="/skip/emplist";
                        }
                    }
                })
            } else if(obj.event === 'no'){//启用
                $.ajax({
                    url: '/wxgl/set',
                    type: 'post',
                    data: {
                        wxid:data.wxid,
                        status:data.status,
                    },
                    dataType: 'json',
                    success : function(data) {
                        if (data){
                            //执行重载
                            $('.layui-laypage-btn').click();
                            //document.location.href="/skip/emplist";
                        }
                    }
                })
            }
        })


        // //启用禁用
        // function aaa(data){
        //     var status = data.status;
        //     var btns = "";
        //     if (status == 1) {
        //         return"启用";
        //     }
        //     if (status == 2) {
        //         btns += '<span style="color:#ed2a4a">禁用</span>';
        //     }
        //     return btns;
        // }
    });
</script>
</html>